package feeinterface.action.protocol;

import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.ulwx.tool.HttpUtils;
import com.ulwx.tool.NetUtils;
import com.ulwx.tool.RequestUtils;
import feeinterface.action.BaseAction;
import feeinterface.utils.URLConfig;

/**
 * 
 * @author 黄杰
 * 
 */
public class Pro010002Action extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8140975201547279966L;
	/**
	 * 
	 */
	private static Logger log = Logger.getLogger(Pro010002Action.class);

	/**
	 * 
	 * @return
	 */
	public String res() {
		return "ok";
	}

	/**
	 * 
	 * @return
	 */
	public String ListData() {
		ActionContext ctx = ActionContext.getContext();
	
		RequestUtils ru = this.getRequestUtils();
		HttpServletRequest request = ServletActionContext.getRequest();
		log.debug("url="+request.getContextPath());
		String url =URLConfig.ROOT+"?";
		// request.getRequestURL();//request.getRequestURI();
		// for (String name : rParms.keySet()) {
		// if (StringUtils.hasText(ru.getString(name))) {
		// url = url + name + "=" + ru.getString(name) + "&";
		// }
		// }
		String queryStr = NetUtils.urlMapToQueryStr(ru.getrParms());
		url = url + "" + queryStr + "&Debug=true";
		log.debug("URL=" + url);
		String result = "";
		try {
			result = HttpUtils.get(url, "utf-8",200000);
		} catch (Exception e) {
			e.printStackTrace();
		}
		String res = "请求地址:<br/>&nbsp;&nbsp;<div style=\"word-wrap:  break-word; overflow:hidden; \">"
				+ url + "</div><br/><br/>响应字符串:<br/>&nbsp;&nbsp;";
		ctx.put("json", res + "<pre>" + result + "</pre>");

		return "json";
	}
}
